#  /**
#  * Copyright (c) 2022 Beijing Jiaotong University
#  * PhotLab is licensed under [Open Source License].
#  * You can use this software according to the terms and conditions of the [Open Source License].
#  * You may obtain a copy of [Open Source License] at: [https://open.source.license/]
#  *
#  * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
#  * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
#  * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
#  *
#  * See the [Open Source License] for more details.
#  */
#  /**
#  * Author: Zheng Wang
#  * Created: Jun. 27, 2022
#  * Supported by: National Key Research and Development Program of China
#  */

"""
    To describe global parameter in a simulation task
"""
# 仿真任务全局变量
from phot_engine.globals.engine_exception import VerificationError
from phot_engine.computing_graph.parameter import Parameter

class TaskGlobalParameter:

    def __init__(self, global_parameter_list):
        self.__global_parameter_dict = {}
        """
            全局系统仿真参数字典
            {
                "参数名":Parameter类型
            }
        """
        if isinstance(global_parameter_list, list):
            for global_parameter in global_parameter_list:
                if isinstance(global_parameter, Parameter):
                    self.__global_parameter_dict[global_parameter.param_name] = global_parameter
                else:
                    raise ValueError(
                        "element in param_list should be Parameter type not {}".format(type(global_parameter_list[0])))
        else:
            raise VerificationError(
                "global_parameter_list should be list type not {}".format(type(global_parameter_list)))

    def get_global_parameter_dict(self) -> dict:
        """
            {
                "参数名": Parameter对象
            }
        :return:
        """
        return self.__global_parameter_dict
